﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy2_6
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int start = int.Parse(textBox1.Text);
            int end = int.Parse(textBox2.Text);
            textBox3.Text = ""; // 清空历史结果

            // for循环遍历年份范围
            for (int year = start; year <= end; year++)
            {
                // 闰年判断条件：普通闰年 或 世纪闰年
                bool isLeap = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
                if (isLeap)
                {
                    // 用\t分隔年份，实现对齐；每5个年份换行（优化显示）
                    textBox3.Text += year.ToString() + "\t";
                    if ((year - start + 1) % 5 == 0)
                    {
                        textBox3.Text += "\r\n"; // 换行
                    }
                }
            }
        }
    }
}
